<template>
    <pageBox>
        <view class="head">
            <view class="portrait" @tap="bindLogo">
                <image :src="wxImg ? wxImg :wxImgs"></image>
            </view>
        </view>

        <view class="body">
            <tr>
                <td class="body-in">
                    <view class="">
                        <img src="../../static/images/icon/icon_company@3x.png" class="t"><img>
                        <text class="body-left">工作单位</text>
                    </view>
                    <text class="body-right">{{array.company_name}}</text>
                    <text class="body-right" v-show="array.company_name == ''">(未填写)</text>
                </td>
            </tr>
            <tr v-show="role_grade1">
                <td class="body-in">
                    <view class="">
                        <img src="../../static/images/icon/icon_dynamic@3x.png" class="t"><img>
                        <text class="body-left">用户角色</text>
                    </view>
                    <text class="body-right">{{array.role_name}}</text>
                </td>
            </tr>
        </view>
        <!-- <view class="body" v-if="role_grade2 ===2 || role_grade3 ===3">
            <tr>
                <td class="body-in">
                    <view class="">
                        <img src="../../static/images/icon/icon_dynamic.png" class="t"><img>
                        <text class="body-left">账号状态</text>
                    </view>
                    <text class="body-right">{{array.activation_status}}</text>
                </td>
            </tr>
            <tr>
                <td class="body-in">
                    <view>
                        <img src="../../static/images/icon/icon_deadline.png" class="t"><img>
                        <text>有效期</text>
                    </view>
                    <text class="body-right">{{ array.operation_time}}</text>
                </td>
            </tr>
        </view> -->

        <!-- 底部 -->
        <view class="foot">
            <!-- <tr v-if="role_grade2==2 || role_grade3==3"> -->
            <tr v-if="isPermission('order_list')">
                <td class="foot-in" @tap="bindPay">
                    <view class="">
                        <img src="../../static/images/icon/icon_payment@3x.png" class="t"><img>
                        <text class="foot-left">支付中心</text>
                    </view>
                    <image src="../../static/images/icon/icon_next.png" class="foot-right"></image>
                </td>
            </tr>
            <tr v-if="isPermission('trade_list')">
                <td class="foot-in" @tap="bindpayHistory">
                    <view class="">
                        <img src="../../static/images/icon/支付记录.png" class="t"><img>
                        <text class="foot-left">支付记录</text>
                    </view>
                    <image src="../../static/images/icon/icon_next.png" class="foot-right"></image>
                </td>
            </tr>
            <tr>
                <td class="foot-in" @tap="bindConsult">
                    <view class="">
                        <img src="../../static/images/icon/icon_information_news@3x.png" class="t"><img>
                        <text class="foot-left">资讯中心</text>
                    </view>
                    <image src="../../static/images/icon/icon_next.png" class="foot-right"></image>
                </td>
            </tr>
            <tr>
                <td class="foot-in" @tap="binDPassword">
                    <view class="">
                        <img src="../../static/images/icon/icon_change_password@3x.png" class="t"><img>
                        <text class="foot-left">修改密码</text>
                    </view>
                    <image src="../../static/images/icon/icon_next.png" class="foot-right"></image>
                </td>
            </tr>
            <tr>
                <td class="foot-in" @tap="bingIdea">
                    <view class="">
                        <img src="../../static/images/icon/icon_feedback@3x.png" class="t"><img>
                        <text class="foot-left">意见反馈</text>
                    </view>
                    <image src="../../static/images/icon/icon_next.png" class="foot-right"></image>
                </td>
            </tr>
            <tr>
                <td class="foot-in" @tap="bingMy">
                    <view class="">
                        <img src="../../static/images/icon/关于我们.png" class="t"><img>
                        <text class="foot-left">联系我们</text>
                    </view>
                    <image src="../../static/images/icon/icon_next.png" class="foot-right"></image>
                </td>
            </tr>
            <tr>
                <td class="foot-in">
                    <view class="">
                        <img src="../../static/images/icon/版本.png" class="t"><img>
                        <text class="foot-left">版本号</text>
                    </view>
                    <view class="foot-right">1.2</view>
                </td>
            </tr>
        </view>
        <view>
            <button class="outLogin" @tap="outLogin">退出登录</button>
        </view>
    </pageBox>
</template>

<script>
import {
    request
} from "../../comon/js/request.js"
export default {
    data() {
        return {
            role_grade1: 99,
            role_grade2: 99,
            role_grade3: 99,
            array: {},
            wxImgs: "",
            wxImg: ""
        };
    },
    onShow() {
        // let wxImg = uni.getStorageSync("wxImg")
        let useMsg = uni.getStorageSync("useMsg")
        this.getMy()
        this.getUserRank_type()
        this.wxImg1()
        console.log(useMsg, "useMsguseMsguseMsguseMsguseMsg")
    },
    watch: {
        "img_pic"() {
            this.getMy()
        }
    },
    methods: {
        //支付权限/ 记录
         isPermission(name) {
            let data = uni.getStorageSync("paymentManagement") // 缓存起来的数组
            if (data.length) {
                return data.includes(name)
            }
            return false
        },
        wxImg1() {
            this.wxImg = uni.getStorageSync("wxImg")
        },
        //获取身份
        getUserRank_type() {
            request({
                url: "v1/passport/detail"
            }).then(res => {
                uni.setStorageSync("role_grade", res.data.result.role_grade)
                let role_grade = uni.getStorageSync("role_grade")
                if (role_grade == 1) {
                    this.role_grade1 = 1
                } else if (role_grade == 2) {
                    this.role_grade2 = 2
                } else if (role_grade == 3) {
                    this.role_grade3 = 3
                }
                console.log(this.role_grade1)
            })
        },
        //退出登录
        outLogin() {
            uni.showModal({
                title: '是否需要退出',
                success: function (res) {
                    if (res.confirm) {
                        uni.clearStorage();
                        uni.redirectTo({
                            url: "../login/login"
                        })
                    } else if (res.cancel) {
                        console.log('用户点击取消');
                    }
                }
            });
        },
        // 获取我的信息
        getMy() {
            // console.log(uni.getStorageSync("useMsg"),"2222222222useMsguseMsguseMsguseMsg")
            request({
                url: `v1/passport/detail?${uni.getStorageSync("useMsg")}`,
                method: "GET"
            }).then(res => {
                console.log(res, "我的用户信息")
                this.array = res.data.result
                if (res.data.result.avatarUrl) {
                    this.wxImg = res.data.result.avatarUrl
                }else{
                    this.wxImg = "../../static/logo.png"
                }
               
            })
        },
        bingMy() {
            uni.navigateTo({
                url: "./aboutMy/aboutMy"
            })
        },
        bindpayHistory() {
            uni.navigateTo({
                url: "./payHistory/payHistory"
            })
        },
        bindPay() {
            uni.navigateTo({
                url: "./pay/pay"
            })
        },
        bindConsult() {
            uni.navigateTo({
                url: "./catalog2/catalog2"
            })
        },
        binDPassword() {
            uni.navigateTo({
                url: "./password/password"
            })
        },
        bingIdea() {
            uni.navigateTo({
                url: "./idea/idea"
            })
        },
        bindLogo() {
            uni.navigateTo({
                url: `./personage/personage?id=${this.useMsg}`
            })
        }
    },
}
</script>

<style lang="less">
page {
    background: #eff1f3;
}

.t {
    position: relative;
    left: 10rpx;
    top: 15rpx;
}

.outLogin {
    margin-top: 30rpx;
    color: white;
    height: 94rpx;
    width: 410rpx;
    background: #0a68a3;

}

page {
    background: #eff1f3 ;

    image {
        width: 40rpx;
        height: 40rpx;
    }

    .head {
        height: 170rpx;
        background: #0a68a3;
        display: flex;
        justify-content: center;

        .portrait {

            image {
                width: 140rpx;
                height: 140rpx;
                border-radius: 50%;
            }
        }
    }

    .body {
        border-radius: 5rpx;
        margin-left: 15rpx;
        width: 720rpx;
        height: 200rpx;
        background: #ffffff;
        position: relative;
        top: -20rpx;

        .body-in {
            height: 100rpx;
            display: flex;
            justify-content: space-between;
            border-bottom: 1rpx solid #f3f3f3;
            align-content: center;
            position: relative;
            align-content: center;

            .body-left {
                line-height: 100rpx;
            }

            img {
                width: 55rpx;
                height: 55rpx;
            }
        }

        .body-right {
            line-height: 100rpx;
            margin-right: 15rpx;
        }

    }

    .foot {
         border-radius: 5rpx;
        width: 720rpx;
        height: 710rpx;
        background: #ffffff;
        margin-left: 15rpx;

        .foot-in {
            height: 100rpx;
            display: flex;
            justify-content: space-between;
            border-bottom: 1rpx solid #f3f3f3;
            align-content: center;
            position: relative;
            align-content: center;

            .foot-left {
                line-height: 100rpx;
            }

            img {

                width: 50rpx;
                height: 50rpx;
            }

            .foot-right {
                padding-top: 30rpx;
                margin-right: 15rpx;
            }
        }

    }
}
</style>
